package com.example;

import org.glassfish.grizzly.http.server.HttpServer;
import org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpServerFactory;
import org.glassfish.jersey.server.ResourceConfig;

import java.io.IOException;
import java.net.URI;

/**
 * 功能描述: TODO <br/>
 * 创建时间: 2016/8/2<br/>
 *
 * @author QiuYang
 */
public class Main {
    public static final String BASE_URL = "http://localhost:8080/myapp/";

    public static HttpServer startServer(){
        final ResourceConfig resourceConfig = new ResourceConfig().packages("com.example");
        return GrizzlyHttpServerFactory.createHttpServer(URI.create(BASE_URL), resourceConfig);
    }

    public static void main(String[] args) throws IOException {
        final HttpServer server = startServer();
        System.out.println(String.format("Jersey app started with WADL available at sapplication.wadl\nHit enter to stop it...", BASE_URL));
        System.in.read();
        server.shutdown();
    }
}
